﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;

using Com.Web.coffinegurunaru.AppLogic.Page;

using Com.Framework;
using Com.Framework.Data;
using Com.Library.DB.Event;
using Com.Library.Page;


namespace Com.Web.coffinegurunaru.manager.Event
{
	public partial class eventMethod : ManagerAjaxPage
	{
		public string[] Create(string StartDateString, string EndDateString, string PublicationDateString, string ImageUrl, string BigImageUrl, string Title, string Content,
			string BigImageUrl2, string BigImageUrl3, string BigImageUrl4, string BigImageUrl5, byte CodeContent
			)
		{
			string[] retVal = new string[2];
			EventModel.Create(StartDateString, EndDateString, PublicationDateString, ImageUrl, BigImageUrl, Title, Content, true, this.WebCookies.ManagerName,
				BigImageUrl2, BigImageUrl3, BigImageUrl4, BigImageUrl5, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, CodeContent
				);
			retVal[0] = "success";

			return retVal;
		}

		public string[] GetList(byte SearchType, int PageNo, byte PageSize)
		{
			bool Current = false;
			if (SearchType == 0)
				Current = false;
			else
				Current = true;
			ListData<EventEntity, OutputEntity> result = EventModel.GetList(Current, null, PageNo, PageSize);
			Dictionary<string, object> properties = new Dictionary<string,object>();
			properties.Add("EventList", result.Record);
			string[] retVal = new string[2];
			retVal[0] = ViewManager<_event>.Render("/manager/Event/eventList.ascx", properties);
			retVal[1] = result.Output.CntTotal.ToString();
			return retVal;
		}

		public string[] Modify(int EventSN, string StartDateString, string EndDateString, string PublicationDateString, string ImageUrl, string BigImageUrl, string Title, string Content,
			string BigImageUrl2, string BigImageUrl3, string BigImageUrl4, string BigImageUrl5, byte CodeContent
			)
		{
			string[] retVal = new string[2];
			EventModel.Modify(EventSN, StartDateString, EndDateString, PublicationDateString, ImageUrl, BigImageUrl, Title, Content, true, this.WebCookies.ManagerName,
				BigImageUrl2, BigImageUrl3, BigImageUrl4, BigImageUrl5, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, CodeContent
				);
			retVal[0] = "success";
			return retVal;
		}

		public string GetInfo(int EventSN)
		{
			EventEntity item = EventModel.GetInfo(EventSN);
			Dictionary<string, object> properties = new Dictionary<string, object>();
			properties.Add("EventInfo", item);
			string retVal = string.Empty;
			retVal = ViewManager<_event>.Render("/manager/Event/eventinfo.ascx", properties);
			return retVal;
		}

		public string GetStateInfo(int EventSN)
		{
			EventEntity item = EventModel.GetInfo(EventSN);
			Dictionary<string, object> properties = new Dictionary<string, object>();
			properties.Add("EventInfo", item);
			string retVal = string.Empty;
			retVal = ViewManager<_event>.Render("/manager/Event/eventinfostat.ascx", properties);
			return retVal;
		}

		public void Remove(int EventSN)
		{
			EventModel.Remove(EventSN);
		}

		public string[] UserList(int EventSN, int PageNo, byte PageSize)
		{
			ListData<EventCommentWriterEntity, OutputEntity> result = EventModel.CommentWriterGetList(EventSN, PageNo, PageSize);
			Dictionary<string, object> properties = new Dictionary<string, object>();
			properties.Add("UserList", result.Record);
			string[] retVal = new string[2];
			retVal[0] = ViewManager<_event>.Render("/manager/Event/userlist.ascx", properties);
			retVal[1] = result.Output.CntTotal.ToString();
			return retVal;
		}

		public string[] CommentGetList(int EventSN, int PageNo, byte PageSize)
		{
			ListData<EventCommentEntity, OutputEntity> result = EventModel.CommentGetList(EventSN, PageNo, PageSize);
			Dictionary<string, object> properties = new Dictionary<string, object>();
			properties.Add("CommentList", result.Record);
			string[] retVal = new string[2];
			retVal[0] = ViewManager<_event>.Render("/manager/Event/commentlist.ascx", properties);
			retVal[1] = result.Output.CntTotal.ToString();
			return retVal;
		}

		public void CommentRemove(int EventCommentSN)
		{
			EventModel.CommentRemove(EventCommentSN);
		}
	}
}
